package com.gpnu.crm.domain;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.format.annotation.DateTimeFormat;

import com.alibaba.fastjson.JSONObject;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

//跟进历史记录
@Data
public class CustomerTraceHistory {
	private Long id; 
	//转换时间格式
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date traceTime; //跟进时间
	private String traceDetails; //跟进记录
	private Integer traceResult; //跟进结果
	private String remark; //备注
	private Date inputTime; //录入时间
	
	private Customer customer; //客户 
	private SystemDictionaryItem type;//交流方式
	private Employee inputUser; 
	
	public String getTraceResultName() {
		String msg = "";
		switch (traceResult) {
		case 1:
			msg = "差";
			break;
		case 2:
			msg = "中";
			break;
		case 3:
			msg = "优";
			break;		
		}
		return msg;
	}
	
	public String getJson() throws Exception {
		Map<String, Object> map = new HashMap();
		map.put("id", id);
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		map.put("traceTime", format.format(traceTime));
		map.put("traceDetails", traceDetails);
		map.put("typeId", type.getId());
		map.put("traceResult", traceResult);
		map.put("remark", remark);
		map.put("customerId", customer.getId());
		map.put("customerName", customer.getName());
		map.put("inputUserId", inputUser.getId());
		map.put("inputUserName", inputUser.getName());
		return JSONObject.toJSONString(map);
	}


	
}